package com.atguigu.springcloud.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


//RabbitMQ-CORE配置
@Configuration
public class RabbitMQ_CORE_Config {

  //交换机
  @Bean
  public DirectExchange MOVIE_TICKET_EXCHANGE_DIRECT() {
    return new DirectExchange(RabbitMQConst.MOVIE_TICKET_EXCHANGE, true, false);
  }

  //队列
  @Bean
  public Queue MOVIE_TICKET_QUEUE() {
    return new Queue(RabbitMQConst.MOVIE_TICKET_QUEUE, true, false, false);
  }


  //路由键
  @Bean
  Binding MOVIE_TICKET_ROUTINGKEY() {
    return BindingBuilder.bind(MOVIE_TICKET_QUEUE()).to(MOVIE_TICKET_EXCHANGE_DIRECT())
            .with(RabbitMQConst.MOVIE_TICKET_ROUTINGKEY);
  }
}
